#include "stdafx.h"
#include "ticker.h"

Clock::Ticker::Ticker( const int aFPS )
:myFramesPerSecond(aFPS), myTickRate(1.0f/aFPS)
{
	myAccumulatedTime = 0;
}

Clock::Ticker::~Ticker()
{

}

void Clock::Ticker::Update( const float aDelta )
{
	myAccumulatedTime += aDelta;
	if(myAccumulatedTime > 10)
	{
		//assert(0 && "FUCK IT");
	}
}

const bool Clock::Ticker::GetTick()
{
	if(myAccumulatedTime > myTickRate)
	{
		myAccumulatedTime -= myTickRate;
		return true;
	}

	return false;
}

const int Clock::Ticker::GetAccumulatedTicks()
{
	int numberOfTicks = 0;

	while( myAccumulatedTime > myTickRate )
	{
		myAccumulatedTime -= myTickRate;
		numberOfTicks++;
	}

	return numberOfTicks;
}

const float Clock::Ticker::GetTickRate() const
{
	return myTickRate;
}

void Clock::Ticker::ResetTicker()
{
	myAccumulatedTime = 0;
}